import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-19
 * Time: 23:26
 */
public class Test66 {

    public static int[] searchRange(int[] num, int target) {
        int[] ret = new int[2];
        ret[0] = ret[1] = -1;
        int n = num.length;
        int left = 0, right = n-1;
        if(n == 0) {
            return ret;
        }
        // 左端点
        while(left < right) {
            int mid = left + (right-left) / 2;
            if(num[mid] < target) {
                left = mid+1;
            }else {
                right = mid;
            }
        }

        if(num[left] == target) {
            ret[0] = left;
        }else {
            return ret;
        }
        // 右端点
        left = 0; right = n-1;
        while(left < right) {
            int mid = left + (right-left+1) / 2;
            if(num[mid] <= target) {
                left = mid;
            }else {
                right = mid-1;
            }
        }
        ret[1] = left;
        return ret;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int target = sc.nextInt();
        int[] ret = searchRange(num,target);
        System.out.println(Arrays.toString(ret));
    }
}
